import {Injectable} from '@angular/core';
import {HttpService} from "app/core/http/http.service";
import {ToolsService} from "app/shared/service/tools/tools.service";
import * as API from "@api/index";

@Injectable()
export class MixService {

  constructor(public http: HttpService,
              public tool: ToolsService) {
  }

  /**
   * @description 获取轮播图
   * @author ouyqx-691
   * @date 2017-09-11
   */
  getSlider() {
    const url: string = API.AD_LIST_URL + '?adsType=banner&showPosition=45&rows=10';
    return this.http.get(url).map((res) => res.json());
  };

  /**
   * @description 获取推荐商品布局信息
   * @author ouyqx-691
   * @date 2017-09-11
   */
  getGoodsModule() {
    const url = API.GOODS_MODULE + '?displayPosition=0&deviceType=4';
    return this.http.get(url).map((res) => res.json());
  };

  /**
   * @description 获取推荐商品
   * @author ouyqx691
   * @date 2017-09-11
   */
  getRecommendGoods(params) {
    const url: string = API.RECOMMEND_GOODS + '?' + this.tool.param(params);
    return this.http.get(url).map((res) => res.json());
  };

  /**
   * @description 获取专题类型
   * @author ouyqx-691
   * @date 2017-09-11
   */
  getGoodsType() {
    const url: string = API.IP_AUTH_SERVICE;
    return this.http.get(url).map((res) => res.json());
  };
}
